package com.foton.designmodel.decorator.impl;

import com.foton.designmodel.decorator.orderprice.MoneySum;
import com.foton.designmodel.decorator.orderprice.entity.Order;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


/**
 * 基础价格计算：购买商品个数 * 商品单价
 */

@Slf4j
@Component("basePriceSum")
public class BasePriceSum implements MoneySum {

    @Override
    public Order money(Order order) {
        int baseTotal = order.getPrice() * order.getAmount();
        order.setPayMoney(baseTotal);
        log.info("订单【基础价格计算】的结算金额 {}", order);

        return order;
    }
}
